<template>
  <div class="app-container">
    <div class="dashboard-container">
      <!-- 今日数据面板 -->
      <div class="data-panel daily-data-panel">
        <div class="panel-header">
          <h3 class="panel-title">今日数据</h3>
          <div>{{ getCurrentDate() }}</div>
          <div class="panel-date">信息数据></div>
        </div>
        <div class="data-content">
          <!-- 营业额卡片 -->
          <div class="highlight-card turnover-card">
            <div class="card-label">营业额</div>
            <div class="card-value">¥{{ todayCount.amount }}</div>
          </div>
          <!-- 其他指标 -->
          <div class="metrics-container">
            <div class="metric-item">
              <div class="metric-label">有效订单</div>
              <div class="metric-value">{{ todayCount.allStatus }}</div>
            </div>
            <div class="metric-item">
              <div class="metric-label">平均客单价</div>
              <div class="metric-value">¥{{ todayCount.average }}</div>
            </div>
            <div class="metric-item">
              <div class="metric-label">订单完成率</div>
              <div class="metric-value success-value">{{ todayCount.proprotion }}%</div>
            </div>
          </div>
        </div>
      </div>
      <!-- 订单管理面板 -->
      <div class="data-panel order-panel">
        <div class="panel-header">
          <h3 class="panel-title">订单管理</h3>
          <div>{{ getCurrentDate() }}</div>
          <div class="panel-date">
            <router-link :to=" '/dining/orders' " class="link-type"> 订单明细></router-link>
          </div>
        </div>
        <div class="data-content">
          <div class="status-grid">
            <div class="status-card pending-card">
              <div class="status-label">待接单</div>
              <div class="status-value">{{ todayCount.status1 }}</div>
            </div>
            <div class="status-card delivery-card">
              <div class="status-label">待配送</div>
              <div class="status-value">{{ todayCount.status3 }}</div>
            </div>
            <div class="status-card completed-card">
              <div class="status-label">已完成</div>
              <div class="status-value">{{ todayCount.status5 }}</div>
            </div>
            <div class="status-card cancelled-card">
              <div class="status-label">已取消</div>
              <div class="status-value">{{ todayCount.status6 }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
      <el-tab-pane :label="'待接单(' + todayCount.status1 +')' " name="1">
        <div class="container">
          <el-table v-loading="loading" :data="ordersList" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column label="ID" align="center" prop="id"/>
            <el-table-column label="订单编号" align="center" prop="orderNo"/>
            <el-table-column label="订单状态" align="center" prop="orderStatus">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.order_status" :value="scope.row.orderStatus"/>
              </template>
            </el-table-column>
            <el-table-column label="订单总金额" align="center" prop="totalAmount"/>
            <el-table-column label="实付金额" align="center" prop="paymentAmount"/>
            <el-table-column label="打包费" align="center" prop="packAmount"/>
            <el-table-column label="运费" align="center" prop="freightAmount"/>
            <el-table-column label="订单备注" align="center" prop="remark"/>
            <el-table-column label="收货人姓名" align="center" prop="receiverName"/>
            <el-table-column label="收货人电话" align="center" prop="receiverPhone"/>
            <el-table-column label="收货人地址" align="center" prop="receiverAddress"/>
            <el-table-column label="配送状态" align="center" prop="deliveryStatus">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.delivery_status" :value="scope.row.deliveryStatus"/>
              </template>
            </el-table-column>
            <el-table-column label="预计送达时间" align="center" prop="estimatedDeliveryTime" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.estimatedDeliveryTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
              </template>
            </el-table-column>

            <el-table-column label="创建时间" align="center" prop="createTime" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <el-button type="text" icon="el-icon-check" @click="handleOrderReceive(scope.row)">接 单
                </el-button>
                <el-button size="mini" type="text" icon="el-icon-share" style="color: red"
                           @click="handleRefuse(scope.row)"
                           v-hasPermi="['system:orders:remove']">拒 单
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />

      </el-tab-pane>
      <el-tab-pane :label=" '待出餐('+todayCount.status2 +')' " name="2">
        <div class="container">
          <el-table v-loading="loading" :data="ordersList" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column label="ID" align="center" prop="id"/>
            <el-table-column label="订单编号" align="center" prop="orderNo"/>
            <el-table-column label="订单状态" align="center" prop="orderStatus">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.order_status" :value="scope.row.orderStatus"/>
              </template>
            </el-table-column>
            <el-table-column label="订单总金额" align="center" prop="totalAmount"/>
            <el-table-column label="实付金额" align="center" prop="paymentAmount"/>
            <el-table-column label="打包费" align="center" prop="packAmount"/>
            <el-table-column label="运费" align="center" prop="freightAmount"/>
            <el-table-column label="订单备注" align="center" prop="remark"/>
            <el-table-column label="收货人姓名" align="center" prop="receiverName"/>
            <el-table-column label="收货人电话" align="center" prop="receiverPhone"/>
            <el-table-column label="餐具数量" align="center" prop="tablewareNumber"/>
            <el-table-column label="餐具数量状态" align="center" prop="tablewareStatus">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.tableware_status" :value="scope.row.tablewareStatus"/>
              </template>
            </el-table-column>
            <el-table-column label="创建时间" align="center" prop="createTime" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <el-button type="text" icon="el-icon-search" @click="handleOrderDispatch(scope.row)">查看详情
                </el-button>
                <el-button size="mini" type="text" icon="el-icon-share" style="color: red"
                           @click="handleCancel(scope.row)"
                           v-hasPermi="['system:orders:remove']">取消出餐
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />

      </el-tab-pane>
      <el-tab-pane :label="'待派送('+todayCount.status3 +')' " name="3">
        <div class="container">
          <el-table v-loading="loading" :data="ordersList" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column label="ID" align="center" prop="id"/>
            <el-table-column label="订单编号" align="center" prop="orderNo"/>
            <el-table-column label="运费" align="center" prop="freightAmount"/>
            <el-table-column label="订单状态" align="center" prop="orderStatus">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.order_status" :value="scope.row.orderStatus"/>
              </template>
            </el-table-column>
            <el-table-column label="订单备注" align="center" prop="remark"/>
            <el-table-column label="收货人姓名" align="center" prop="receiverName"/>
            <el-table-column label="收货人电话" align="center" prop="receiverPhone"/>
            <el-table-column label="收货人地址" align="center" prop="receiverAddress"/>
            <!--            <el-table-column label="配送人id" align="center" prop="deliveryId"/>-->
            <!--            <el-table-column label="配送人姓名" align="center" prop="deliveryName"/>-->
            <!--            <el-table-column label="配送人电话" align="center" prop="deliveryPhone"/>-->
            <el-table-column label="配送状态" align="center" prop="deliveryStatus">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.delivery_status" :value="scope.row.deliveryStatus"/>
              </template>
            </el-table-column>
            <el-table-column label="预计送达时间" align="center" prop="estimatedDeliveryTime" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.estimatedDeliveryTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
              </template>
            </el-table-column>

            <el-table-column label="创建时间" align="center" prop="createTime" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <el-button size="mini" type="success" icon="el-icon-check" @click="handleOrderPick(scope.row)">确认取货
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-tab-pane>

      <el-tab-pane :label=" '派送中('+ todayCount.status4 +')'" name="4">
        <div class="container">
          <el-table v-loading="loading" :data="ordersList" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column label="ID" align="center" prop="id"/>
            <el-table-column label="运费" align="center" prop="freightAmount"/>
            <el-table-column label="订单状态" align="center" prop="orderStatus">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.order_status" :value="scope.row.orderStatus"/>
              </template>
            </el-table-column>

            <el-table-column label="订单备注" align="center" prop="remark"/>
            <el-table-column label="收货人姓名" align="center" prop="receiverName"/>
            <el-table-column label="收货人电话" align="center" prop="receiverPhone"/>
            <el-table-column label="收货人地址" align="center" prop="receiverAddress"/>
            <!--            <el-table-column label="配送人id" align="center" prop="deliveryId"/>-->
            <el-table-column label="配送人姓名" align="center" prop="deliveryName"/>
            <el-table-column label="配送人电话" align="center" prop="deliveryPhone"/>
            <el-table-column label="配送状态" align="center" prop="deliveryStatus">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.delivery_status" :value="scope.row.deliveryStatus"/>
              </template>
            </el-table-column>
            <el-table-column label="预计送达时间" align="center" prop="estimatedDeliveryTime" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.estimatedDeliveryTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
              </template>
            </el-table-column>

            <el-table-column label="创建时间" align="center" prop="createTime" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <el-button size="mini" type="success" icon="el-icon-check" @click="handleOrderFinish(scope.row)">配送完成
                </el-button>
                <el-button type="text" icon="el-icon-delete" style="color: red"
                           @click="handleOrderTransfer(scope.row)"
                           v-hasPermi="['system:orders:remove']">转单配送
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />

      </el-tab-pane>

    </el-tabs>

    <el-dialog title="订单详情" :visible.sync="openOrder" width="1600px" append-to-body>
      <h4>订单跟踪</h4>
      <div style="margin: 20px 0">
        <el-row>
          <el-steps :active="active" finish-status="success" align-center>
            <el-step v-for="item in form.takeoutLogList" :title="item.description"
                     :description="item.logTime"></el-step>
          </el-steps>
        </el-row>
      </div>
      <h4>订单明细</h4>
      <div>
        <el-form ref="form" :model="form" label-width="120px">
          <el-row>
            <el-col :span="8">
              <el-form-item label="订单号">
                <el-input v-model="form.orderNo" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="收货人">
                <el-input v-model="form.receiverName" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="手机号">
                <el-input v-model="form.receiverPhone" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="订单状态">
                <el-select v-model="form.orderStatus" placeholder="暂无" disabled>
                  <el-option v-for="dict in dict.type.order_status" :key="dict.value" :label="dict.label"
                             :value="parseInt(dict.value)"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="下单时间">
                <el-input v-model="form.paymentTime" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="配送人">
                <el-input v-model="form.deliveryName" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="收货时间">
                <el-input v-model="form.receiveTime" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="配送状态">
                <el-select v-model="form.deliveryStatus" placeholder="暂无" disabled>
                  <el-option v-for="dict in dict.type.delivery_status" :key="dict.value" :label="dict.label"
                             :value="dict.value"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="预计送达时间">
                <el-input v-model="form.estimatedDeliveryTime" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="地址">
                <el-input v-model="form.receiverAddress" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="运费">
                <el-input v-model="form.freightAmount" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="打包费">
                <el-input v-model="form.packAmount" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="餐具数量状态">
                <el-select v-model="form.tablewareStatus" placeholder="按餐量提供" disabled>
                  <el-option v-for="dict in dict.type.tableware_status" :key="dict.value" :label="dict.label"
                             :value="parseInt(dict.value)"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="餐具数量">
                <el-input v-model="form.tablewareNumber" placeholder="暂无" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="备注">
                <el-input v-model="form.remark" type="textarea" placeholder="暂无" readonly></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <h4>商品明细</h4>
      <div>
        <el-table :data="form.detailsList" stripe style="width: 100%">
          <el-table-column prop="id" label="id"></el-table-column>
          <el-table-column label="图片" prop="dishImage">
            <template slot-scope="scope">
              <image-preview :src="scope.row.dishImage" :width="50" :height="50"/>
            </template>
          </el-table-column>
          <el-table-column prop="dishName" label="商品"></el-table-column>
          <el-table-column prop="dishFlavor" label="口味">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.t_flavor" :value="scope.row.dishFlavor"/>
            </template>
          </el-table-column>
          <el-table-column prop="quantity" label="数量"></el-table-column>
          <el-table-column prop="dishPrice" label="单价/元"></el-table-column>
          <el-table-column prop="totalPrice" label="总价/元"></el-table-column>
          <el-table-column prop="refundStatus" label="退款状态">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.refund_status" :value="scope.row.refundStatus"/>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定 出 餐</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listOrders,
  getOrders,
  delOrders,
  receiveOrder,
  refuseOrder,
  dispatchOrder,
  pickOrder,
  finishOrder,
  transferOrder,
  todayOrder
} from "@/api/system/orders"

export default {
  name: "Orders",
  dicts: ['order_status', 'pay_method', 'delivery_status', 'tableware_status'],
  data() {
    return {
      activeName: '1',
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 订单表格数据
      ordersList: [],
      // 弹出层标题
      title: "",
      // 是否显示订单详情弹出层
      openOrder: false,
      // 是否显示弹出层
      open: false,
      // 餐具数量状态时间范围
      daterangePaymentTime: [],
      // 餐具数量状态时间范围
      daterangeDeliveryTime: [],
      // 餐具数量状态时间范围
      daterangeReceiveTime: [],
      // 餐具数量状态时间范围
      daterangeEstimatedDeliveryTime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderStatus: null,
      },
      // 表单参数
      form: {},
      //日志激活状态
      active: 0,
      //今日统计数据
      todayCount: {}
    }
  },
  created() {
    this.todayOrderCount();
    this.queryParams.orderStatus = 1
    this.getList()
  },
  methods: {
    /** 查询订单列表 */
    getList() {
      this.loading = true
      this.queryParams.params = {}
      if (null != this.daterangePaymentTime && '' != this.daterangePaymentTime) {
        this.queryParams.params["beginPaymentTime"] = this.daterangePaymentTime[0]
        this.queryParams.params["endPaymentTime"] = this.daterangePaymentTime[1]
      }
      if (null != this.daterangeDeliveryTime && '' != this.daterangeDeliveryTime) {
        this.queryParams.params["beginDeliveryTime"] = this.daterangeDeliveryTime[0]
        this.queryParams.params["endDeliveryTime"] = this.daterangeDeliveryTime[1]
      }
      if (null != this.daterangeReceiveTime && '' != this.daterangeReceiveTime) {
        this.queryParams.params["beginReceiveTime"] = this.daterangeReceiveTime[0]
        this.queryParams.params["endReceiveTime"] = this.daterangeReceiveTime[1]
      }
      if (null != this.daterangeEstimatedDeliveryTime && '' != this.daterangeEstimatedDeliveryTime) {
        this.queryParams.params["beginEstimatedDeliveryTime"] = this.daterangeEstimatedDeliveryTime[0]
        this.queryParams.params["endEstimatedDeliveryTime"] = this.daterangeEstimatedDeliveryTime[1]
      }
      listOrders(this.queryParams).then(response => {
        this.ordersList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.openOrder = false
      // this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        orderNo: null,
        userId: null,
        totalAmount: null,
        paymentAmount: null,
        packAmount: null,
        freightAmount: null,
        orderStatus: null,
        paymentType: null,
        paymentTime: null,
        deliveryTime: null,
        receiveTime: null,
        remark: null,
        receiverName: null,
        receiverPhone: null,
        addressBookId: null,
        receiverAddress: null,
        cancelReason: null,
        cancelTime: null,
        deliveryId: null,
        deliveryName: null,
        deliveryPhone: null,
        deliveryStatus: null,
        estimatedDeliveryTime: null,
        tablewareNumber: null,
        tablewareStatus: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: null
      }
      this.resetForm("form")
    },
    // 切换标签
    handleClick(tab, event) {
      this.handleQuery(tab.name)
    },

    /** 搜索按钮操作 */
    handleQuery(val) {
      this.queryParams.pageNum = 1
      this.queryParams.orderStatus = val
      this.getList();
      this.todayOrderCount();
    },

    /** 统计 */
    todayOrderCount() {
      todayOrder().then(res => {
        console.log(res.data)
        this.todayCount = res.data
      })
    },

    // 当天日期
    getCurrentDate() {
      const date = new Date();
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要+1，并补零
      const day = String(date.getDate()).padStart(2, '0'); // 补零
      return `${year}-${month}-${day}`;
    },


    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },

    //查看详情
    handleOrderDispatch(row) {
      const id = row.id
      console.log(id)
      this.openOrder = true
      getOrders(id).then(res => {
        console.log(res.data)
        this.form = res.data
        this.active = this.form.takeoutLogList.length
      })
    },
    /** 提交出餐*/
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (this.form.id != null) {
          dispatchOrder(this.form.id).then(response => {
            this.$modal.msgSuccess("出餐成功")
            this.openOrder = false
            this.getList()
            this.todayOrderCount();
          })
        }
      })
    },
    //取消出餐
    handleCancel(row) {
      const ids = row.orderNo || this.ids
      this.$modal.confirm('订单号' + ids + '是否确认拒绝出餐？').then(function () {
        return refuseOrder(row.id)
      }).then(() => {
        this.getList()
        this.todayOrderCount();
        this.$modal.msgSuccess("拒单成功")
      })
    },
    //确认接单
    handleOrderReceive(row) {
      const ids = row.orderNo || this.ids
      this.$modal.confirm('订单号' + ids + '是否确认接单？').then(function () {
        return receiveOrder(row.id)
      }).then(() => {
        this.getList()
        this.todayOrderCount();
        this.$modal.msgSuccess("接单成功")
      })
    },
    //拒绝接单
    handleRefuse(row) {
      const ids = row.orderNo || this.ids
      this.$modal.confirm('订单号' + ids + '是否确认拒单？').then(function () {
        return refuseOrder(row.id)
      }).then(() => {
        this.getList()
        this.todayOrderCount();
        this.$modal.msgSuccess("拒单成功")
      })
    },
    handleOrderPick(row) {
      const ids = row.orderNo || this.ids
      this.$modal.confirm('订单号' + ids + '确认已到达取货地点？').then(function () {
        return pickOrder(row.id)
      }).then(() => {
        this.getList()
        this.todayOrderCount();
        this.$modal.msgSuccess("取货成功")
      })
    },

    //完成订单
    handleOrderFinish(row) {
      const ids = row.orderNo || this.ids
      this.$modal.confirm('订单号' + ids + '确认到达收货人地址？').then(function () {
        return finishOrder(row.id)
      }).then(() => {
        this.getList()
        this.todayOrderCount();
        this.$modal.msgSuccess("恭喜你！完成配送")
      })
    },
    //转派订单
    handleOrderTransfer(row) {
      const ids = row.orderNo || this.ids
      this.$modal.confirm('订单号' + ids + '确认转单给其他配送人？').then(function () {
        return transferOrder(row.id)
      }).then(() => {
        this.getList()
        this.todayOrderCount();
        this.$modal.msgSuccess("转单成功")
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.orderNo || this.ids
      this.$modal.confirm('是否确认删除订单编号为"' + ids + '"的数据项？').then(function () {
        return delOrders(ids)
      }).then(() => {
        this.getList()
        this.todayOrderCount();
        this.$modal.msgSuccess("删除成功")
      })
    },

  }
}
</script>

<style>
/* 基础样式 */
.dashboard-container {
  display: flex;
  width: 100%;
  height: 400px;
  font-family: 'Arial', 'Microsoft YaHei', sans-serif;
  gap: 16px;
  padding: 16px;
  box-sizing: border-box;
  background-color: #FFFFFF; /* 统一背景色 */
}

.data-panel {
  flex: 1;
  height: 100%;
  border-radius: 8px;
  padding: 16px;
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* 统一阴影效果 */
  background-color: #e5f2fa; /* 统一面板背景色 */
}

/* 面板头部 */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #afaeae; /* 统一分隔线颜色 */
}

.panel-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333; /* 统一标题颜色 */
}

.panel-date {
  font-size: 14px;
  color: #666; /* 统一日期颜色 */
}

/* 数据内容区域 */
.data-content {
  height: calc(100% - 50px);
  display: flex;
  flex-direction: column;
}

/* 高亮卡片样式 */
.highlight-card {
  padding: 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  border-left: 3px solid #1c84c6; /* 保留蓝色强调色 */
  background-color: white;
}

.card-label, .metric-label, .status-label {
  font-size: 14px;
  margin-bottom: 8px;
  color: #666; /* 标签文字颜色 */
}

.card-value {
  font-size: 24px;
  font-weight: bold;
  color: #333; /* 主数值颜色 */
}

/* 指标容器 */
.metrics-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  flex: 1;
}

.metric-item {
  background-color: #f8f9fa; /* 浅灰色背景 */
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04); /* 轻微阴影 */
}

.metric-value {
  font-size: 18px;
  font-weight: 500;
  color: #333; /* 数值颜色 */
}

.success-value {
  /*color: #52c41a; !* 成功状态保留绿色 *!*/
}

/* 订单状态网格 */
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  height: 100%;
}

.status-card {
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04); /* 轻微阴影 */
  background-color: #f8f9fa; /* 统一浅灰色背景 */
}

.status-value {
  font-size: 22px;
  font-weight: bold;
  color: #333; /* 数值颜色 */
}

/* 状态卡片特殊处理（仅保留边框颜色区分） */
.pending-card {
  border-top: 3px solid #faad14; /* 待接单-橙色边框 */
}

.delivery-card {
  border-top: 3px solid #1890ff; /* 待配送-蓝色边框 */
}

.completed-card {
  border-top: 3px solid #52c41a; /* 已完成-绿色边框 */
}

.cancelled-card {
  border-top: 3px solid #f5222d; /* 已取消-红色边框 */
}
</style>
